﻿using DatabaseCore.Dto;
using FirstFloor.ModernUI.Presentation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Export.Ui.ViewModel
{
    public class AtpDetailViewModel
    {
        private OrderDetailViewModel _orderDetailVM;
        public AtpDetailViewModel(OrderDetailViewModel orderDetailVM, List<Atp> atps)
        {
            _orderDetailVM = orderDetailVM;
            if (atps != null)
            {
                Atps = atps;
            }
            initailCommand();
        }

        public RelayCommand CloseCommand { get; set; }
        public List<Atp> Atps { get; set; }
        public Atp SeletedItem { get; set; }
        public string SelectedPlant
        {
            get
            {
                if (SeletedItem == null)
                {
                    return "";
                }
                return SeletedItem.Plant;
            }
        }

        public int SelectedAtp
        {
            get
            {
                if (SeletedItem == null)
                {
                    return 0;
                }
                return SeletedItem.ATPQty;
            }
        }

        private void initailCommand(){
            CloseCommand = new RelayCommand(Close); 
        }

        private void Close(object parameter)
        {
            _orderDetailVM.AtpDetailDialog.Close();
        }
    }
}
